package com.xbibo.autoconfigure.dal.redis.support;

import org.springframework.dao.DataAccessException;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.core.RedisCallback;
import org.springframework.data.redis.core.StringRedisTemplate;

/**
 * 类/接口注释
 *
 * @author jiangnan.zjn@alibaba-inc.com
 * @createDate 2017/9/23
 */
public class RedisOps {

    /**
     * 设置过期时间
     * @param stringRedisTemplate template
     * @param key key
     * @param seconds 过期时间
     * @return boolean
     * @author BravoZu
     */
    public static boolean expire(StringRedisTemplate stringRedisTemplate, final String key, final long seconds) {
        stringRedisTemplate.execute((RedisCallback<Boolean>)connection -> connection.expire(key.getBytes(), seconds));
        return true;
    }
}
